package com.yukh.test.hibernate.ex1;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.Test;

public class HibernateDemo {
	
	@Test
	public void initHiber(){
		Configuration cf = new Configuration().configure("com/yukh/test/hibernate/ex1/hibernate.cfg.xml");
		SessionFactory sf = cf.buildSessionFactory();
		Session session = sf.openSession();
		session.beginTransaction();
		
		Student stu = new Student();
		stu.setStuName("stu1");
		stu.setCreateTime(new Date());
		session.save(stu);
		
//		List list = session.createQuery("from Student").list();
//		System.out.println("====" + list.size());
		
		session.getTransaction().commit();
	}
}
